﻿@namespace MudBlazor

<div class="mud-treeview-item-arrow">
    @if (Visible)
    {
        <MudIconButton OnClick="@ToggleAsync" Icon="@ExpandedIcon"
                       Class="@(Expanded? "mud-treeview-item-arrow-expand mud-transform" : "mud-treeview-item-arrow-expand")"></MudIconButton>
    }
</div>
 
@code {
    [Parameter]
    public bool Visible { get; set; }

    [Parameter]
    public bool Expanded { get; set; }

    [Parameter]
    public EventCallback<bool> ExpandedChanged { get; set; }

    [Parameter]
    public string ExpandedIcon { get; set; } = Icons.Material.Filled.ChevronRight;

    private Task ToggleAsync()
    {
        Expanded = !Expanded;
        return ExpandedChanged.InvokeAsync(Expanded);
    }
}
